package com.badger.generator;

import java.util.Arrays;

import com.badger.generator.constant.DataBaseDriver;
import com.badger.generator.entity.GeneratorAttr;
import com.badger.generator.enums.MybatisPlusEnum;
import com.badger.generator.pattern.AutoGeneratorTemplateFactory;

/**
 * test pgsql
 * @author liqi
 */
public class AppTestPostgreSql {
    public static void main(String[] args) {
        String url = "jdbc:postgresql://218.1.116.178:54322/foresee";
        String user = "ecm";
        String password = "FUo248s2";
        GeneratorAttr attr = new GeneratorAttr();
        attr.setAuthor("liqi");// 作者名字 ;
        attr.setPackagePath("com.tellhow.foresee");// 创建的类的包路径
        attr.setDriver(DataBaseDriver.POSTGRE_SQL);
        attr.setUrl(url);
        attr.setUser(user);
        attr.setPassword(password);
        // 类名需要过滤的开头 eg：T,TB……，默认为null，不过滤表头.
        attr.setIncludePrefix(Arrays.asList("T", "TB"));
        // 需要生成的表，默认为null，生成该数据库下，所有的表.
         attr.setTables(Arrays.asList("t_company"));

        // 生成文件的目录
        String path = "D:\\springwind";
        // String path = System.getProperty("user.dir") +
        // "\\src\\main\\java\\com\\badger\\energy";
        AutoGeneratorTemplateFactory autoFactory = AutoGeneratorTemplateFactory.getInstance(attr);
        // autoFactory.buildTkModel(null, true, false);
        // autoFactory.buildMapper("com.tellhow.dsm.base.BaseMapper");
        // autoFactory.buildService("com.tellhow.dsm.base.BaseService",
        // "com.tellhow.dsm.base.BaseServiceImpl");

        autoFactory.buildMpModel(null, true, true, MybatisPlusEnum.VSERSION.getClassName());
        autoFactory.buildMapper(MybatisPlusEnum.MAPPER.getClassName());
        autoFactory.buildService(MybatisPlusEnum.SERVICE.getClassName(), MybatisPlusEnum.SERVICE_IMPL.getClassName());
        autoFactory.write(path).openFile(path);
        // autoFactory.buildExcel(path, "test");
    }
}
